import java.net.*;
public class SocketStateDemo{
	public static void main(String[] args){

		Socket socket = null ;

		try{
			socket = new Socket();

			print(socket.isClosed());
			print(socket.isConnected());

			SocketAddress address = new InetSocketAddress("www.baidu.com",80);
			socket.connect(address);


		}catch(Exception e){
			e.printStackTrace();
		}finally{
			try{
				socket.close();
				print(socket.isClosed());
				print(socket.isConnected());
			}catch(Exception ex){}
		}


	
	}

	public static void print(Object info){
		System.out.println(info);
	}
}
